<template>
  <div>
    <el-form ref="myform" :model="formItem" label-width="100px" size="mini">
      <el-col :offset="20" :span="4">
        <el-button size="mini" type="primary" @click="ok('submit')">关闭</el-button>
      </el-col>
    </el-form>
  </div>
</template>

<script>
import { detail, create } from '@neu/dcom-ui/api/incidentClose'
const formItem = {

}
export default {
  name: 'IncidentCloseForm',
  components: {

  },
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 编辑的表单内容
      formItem: {
        ...formItem
      }
    }
  },
  watch: {

  },
  created() {
    this.fetch()
  },
  methods: {
    fetch() {
      if (this.workOrderNum !== 'NULL') {
        detail(this.workOrderNum, this.taskId).then(response => {
          this.formItem = {
            ...response.data
          }
        })
      } else {
        this.formItem = {
          ...formItem
        }
      }
    },
    ok(value) {
      this.formItem.workOrderNum = this.workOrderNum
      this.formItem.taskId = this.taskId
      create(this.formItem).then(res => {
        if (res.status === 'success') {
          this.$emit('cancelNewOrderForm', 'refresh')
        }
      })
    },
    reset() {
      this.$refs.myform.resetFields()
      this.formItem = { ...formItem }
    }
  }
}
</script>
